<?PHP


global $conf;

$media=new music;

if(!empty($_GET['order_by']))
{
	$media->options['order'][0]=$_GET['order_by'];
	$media->options['order'][1]='DESC';
	$media->where['type']='song';
}
//echo $conf->canonical;
if(!empty($_GET['letter']))
{
	
	if($_GET['letter']=='all')
	{
		$media->options['letter']=NULL;
	}
	else
	{
	$media->options['letter']=$_GET['letter'];	
	}
}
else
{
$media->options['letter']='a';	
}
$media->get_music();
$headers[]='Id';
$headers[]='Name';
$headers[]='Artist';
$headers[]='Album';
$headers[]='Genre';

$headers[]='<a href="'.$conf->canonical.'&order_by=play">P</a>';
$headers[]='<a href="'.$conf->canonical.'&order_by=finish">F</a>';
$headers[]='<a href="'.$conf->canonical.'&order_by=skip">S</a>';
$headers[]='<a href="'.$conf->canonical.'&order_by=notfound">N</a>';
$headers[]='<a href="'.$conf->canonical.'&order_by=request">r</a>';
$headers[]='Action';
$show[]='id';
$show[]='name';
$show[]='artist';
$show[]='album';
$show[]='genre';
$show[]='play';
$show[]='finish';
$show[]='skip';
$show[]='notfound';
$show[]='request';
$links['Edit']='?q=m/music/d_music.php&cmd=edit&id=';
$ajax['Delete']='m/music/a_delete_music.php';
printformheader('Music','Content Listing');

if(!empty($media->data))
{

	p_table($headers,$media->data,$links,"class='tablesorter'",$show,$ajax,FALSE);

} 

?>

<ul class='paginator'>
	<?PHP
	
	//$pager[$i]='http://'.$_SERVER['HTTP_HOST'].$script_name.$queries.'&page='.$i;
	?>
	<?php
	foreach(range('a', 'z') as $letter) {
		$queries=get_clean_queries();
		$script_name=$_SERVER['SCRIPT_NAME'];
		$link='http://'.$_SERVER['HTTP_HOST'].$script_name.$queries.'&letter='.$letter;
		$all='http://'.$_SERVER['HTTP_HOST'].$script_name.$queries.'&letter=all';
	   ?>
		<li> <a href='<?PHP echo $link;?>'><?PHP echo $letter;?></a> </li>
	<?PHP
	}
	?>
	
	<li> <a href='<?PHP echo $all;?>'>Everything (Slow)</a> </li>

</ul>

<?PHP printformfooter('Add Music','?q=m/music/d_music.php&cmd=add','Add Album','?q=m/music/d_music_album.php&cmd=add',NULL,NULL);?>

